#include<bits/stdc++.h>

using namespace std;
using ll = long long;
#define endl '\n'
/**
 * 螺旋矩阵的递归解法（求出方向字符串）
 * @param n
 * @return
 */
string f(size_t n) {
    if (n == 1)return "";
    if (n == 2)return "RDL";

    return string(n - 1, 'R') + string(n - 1, 'D') + string(n - 1, 'L') + string(n - 2, 'U') + "R" + f(n - 2);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    vector<vector<int>> a(n, vector<int>(n, 0));
    int x = 0, y = 0;
    string s = f(n);
    for (int i = 0, k = 1; k <= n * n; k++, i++) {
        a[x][y] = k;
        char d = s[i];
        switch (d) {
            case 'L':
                y--;
                break;
            case 'R':
                y++;
                break;
            case 'D':
                x++;
                break;
            case 'U':
                x--;
                break;
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cout << a[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}
